Add Postman Sort (LSD Radix Sort) in R#243
Closed
Siddhram wants to merge 2 commits into
Closed
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds an implementation of Postman Sort (LSD Radix Sort) for sorting non-negative integers in R. The algorithm processes digits from least to most significant using stable counting sort, following the typical base-10 radix sort pattern.
Key Changes:
- New implementation of LSD Radix Sort with digit-by-digit counting sort
- Input validation for numeric vectors, non-negative integers only
- Helper functions for finding maximum value and performing counting sort per digit
| # For safety, coerce to integer-like values | ||
| if (any(elements.vec != floor(elements.vec))) stop("postman.sort: values must be integers") | ||
|
|
||
| get.max <- function(a) max(a) |
There was a problem hiding this comment.
The get.max helper function is unnecessary and reduces readability. It simply wraps the built-in max() function without adding any value. Consider using max() directly on line 47 instead.
siriak
requested changes
Oct 23, 2025
| # For safety, coerce to integer-like values | ||
| if (any(elements.vec != floor(elements.vec))) stop("postman.sort: values must be integers") | ||
|
|
||
| get.max <- function(a) max(a) |
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This PR was closed because it has been stalled for 7 days with no activity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implementation provides decimal LSD (Least Significant Digit) Radix Sort in R.
It sorts non-negative integers by repeatedly applying a stable counting sort to each digit, from the least significant to the most significant.
Overview
Features
exp) iterativelyComplexity
n= number of elements,d= number of digits in the maximum element,k= radix/base (10 here)